﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using CompanyHub.ViewModels;

namespace CompanyHub.Converters
{
    public class PackageInstallStateToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is MainViewModel.AppInfo.PackageInstallState)
            {
                MainViewModel.AppInfo.PackageInstallState targetValue;
                if (parameter is string)
                {
                    switch ((string)parameter)
                    {
                        case "Installed":
                            targetValue = MainViewModel.AppInfo.PackageInstallState.Installed;
                            break;
                        case "UnInstalled":
                            targetValue = MainViewModel.AppInfo.PackageInstallState.NotInstalled;
                            break;
                        case "Installing":
                            targetValue = MainViewModel.AppInfo.PackageInstallState.Installing;
                            break;
                        default:
                            targetValue = MainViewModel.AppInfo.PackageInstallState.NotInstalled;
                            break;
                    }
                    return targetValue.Equals(((MainViewModel.AppInfo.PackageInstallState)value)) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
                }
            }
            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
